<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Active Nav Link indicator</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <nav>
    <a href="#">Home</a>
    <a href="#">About</a>
    <a href="#">Protfolio</a>
    <a href="#">Team</a>
    <a href="#">Contact</a>
    <div id="marker"></div>
  </nav>
</body>
<script>
  let marker = document.querySelector('#marker')
  let item = document.querySelectorAll('nav a')

  function indicator(e) {
    marker.style.left = e.offsetLeft + 'px'
    marker.style.width = e.offsetWidth + 'px'
  }

  item.forEach(link => {
    link.addEventListener('click', e => {
      indicator(e.target)
    })
  })
</script>

</html>